package com.ninghushangbao.ninghu.service.Impl;

import com.ninghushangbao.ninghu.entity.Product;
import com.ninghushangbao.ninghu.mapper.ProductMapper;
import com.ninghushangbao.ninghu.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductMapper productMapper;

    @Override
    public void addProduct(Product product) {
        product.setCreateTime(new Date());
        product.setUpdateTime(new Date());
        productMapper.addProduct(product);
    }

    @Override
    public List<Product> selectProduct() {
        return productMapper.selectProduct();
    }

    @Override
    public List<Product> selectProductHome() {
        return productMapper.selectProductHome();
    }

    @Override
    public Product selectProductById(int id) {
        return productMapper.selectProductById(id);
    }

    @Override
    public void updateProduct(Product product) {
        product.setUpdateTime(new Date());
        productMapper.updateProduct(product);
    }

    @Override
    public void deleteProductById(List<Integer> productId) {
        productMapper.deleteProductById(productId);
    }
}
